using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "SoundDetailListSO", menuName = "Sound/SoundDetailListSO", order = 0)]
public class SoundDetailListSO : ScriptableObject
{
    public List<SoundDetails> soundDetailList;

    /// <summary>
    /// 根据声音名获取对应的声音
    /// </summary>
    /// <param name="soundName"></param>
    /// <returns></returns>
    public SoundDetails GetSoundDetails(SoundName soundName)
    {
        return soundDetailList.Find(x => x.soundName == soundName);
    }
}

[System.Serializable]
public class SoundDetails
{
    public SoundName soundName;
    public List<AudioClip> clip;
    [Range(0.1f, 1.5f)]
    public float soundPitchMin = 0.8f;
    [Range(0.1f, 1.5f)]
    public float soundPitchMax = 1.2f;
    [Range(0.1f, 1.5f)]
    public float volume = 1f;
    [Header("起始播放时间")]
    public float startSceond;

    [HideInInspector] public AudioClip currentClip;

    public AudioClip RandomClip
    {
        get
        {
            currentClip = clip[Random.Range(0, clip.Count)];
            return currentClip;
        }
    }

}